import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCz4qki5/7o4ift8ynI4pkWJDoe\n' +
  'ykWBF04Oz86O0q3lrpFJWjjODJY13VXh3dLYWwaiLlChrFQSLPdZ/GzsX8outXhL\n' +
  'WYKInUIt2eggen+InK+JSUmly9j06WYFDJ6KRHV9/aAnNX3R42jCsd/G9C6ePSOY\n' +
  'v7U+/RcHLkK3XSCXVwIDAQAB'

const privateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALPiqSLn/ujiJ+3z\n' +
  'KcjimRYkOh7KRYEXTg7Pzo7SreWukUlaOM4MljXdVeHd0thbBqIuUKGsVBIs91n8\n' +
  'bOxfyi61eEtZgoidQi3Z6CB6f4icr4lJSaXL2PTpZgUMnopEdX39oCc1fdHjaMKx\n' +
  '38b0Lp49I5i/tT79FwcuQrddIJdXAgMBAAECgYEAgAcuQf3EW5O6v4x1jNhaBHw8\n' +
  'MXXdCgfAMqKMbPJdej9IgGCKVXx33FZvrZXnXr1Kd1tnX+n63ATM92rFS2bRykG9\n' +
  '2C8tfNq0WnmCM5DClKqNcdWJkXJEHulk04SjL9pYbDW+6G70Y4UBuCdZrCNBlUK4\n' +
  'aQoUVazSvRAp3vOyXKECQQDs9zYKEI8F9mKgiaHiGzZGS/M1y1pGtLb8Aah97FA+\n' +
  '7BX+yxc5rfoacCsn+inoCUcWyFTSyXT8Ma3c6jQmSbF1AkEAwlWxSNP5rYGjrPNg\n' +
  'nMryTnliSxrZ47sOXh/zCm7vuPYbJW5wkaPg3bt3i+gY1pd+8yx2NRMhkdpLwapy\n' +
  'rLNgGwJBAIkIkNSTLNJq4DAsR1RlHibaxwPF3CflW6gyIUjovqMUjcexlHXDmU1u\n' +
  'rlZJAbDwpI6VPRBEdgVdiUimm4/Er/0CQA2IkjQULwsaQB/HQy8oIv+8DFBWql3l\n' +
  'pPaBGxfa6e7jlLhinIxH8Vz/tS+VFkW7fyfILOM9VdUmcqgmCp5kT4kCQHU+3SJp\n' +
  'xO6Oy75hOJdLgXm9o8bZ7XkuBTggxhMN4Fm9Zcg/aucuh9aSOzdPFe+OTZ2egFiQ\n' +
  '5co7YojPLzJXhKw='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

